shared_info_any_t *live_shinfo,
xen_pfn_t **live_p2m, unsigned long *pfnp);
+int xc_core_arch_get_scratch_gpfn(xc_interface *xch, domid_t domid,
+ xen_pfn_t *gpfn);
+
#if defined (__i386__) || defined (__x86_64__)
# include "xc_core_x86.h"
return xc_core_arch_map_p2m_rw(xch, dinfo, info,
live_shinfo, live_p2m, pfnp, 1);
}
+
+int
+xc_core_arch_get_scratch_gpfn(xc_interface *xch, domid_t domid,
+ xen_pfn_t *gpfn)
+{
+ /*
+ * The Grant Table region space is not used until the guest is
+ * booting. Use the first page for the scratch pfn.
+ */
+ XC_BUILD_BUG_ON(GUEST_GNTTAB_SIZE < XC_PAGE_SIZE);
+
+ *gpfn = GUEST_GNTTAB_BASE >> XC_PAGE_SHIFT;
+
+ return 0;
+}
+
+
/*
* Local variables:
* mode: C
return xc_core_arch_map_p2m_rw(xch, dinfo, info,
live_shinfo, live_p2m, pfnp, 1);
}
+
+int
+xc_core_arch_get_scratch_gpfn(xc_interface *xch, domid_t domid,
+ xen_pfn_t *gpfn)
+{
+ int rc;
+
+ rc = xc_domain_maximum_gpfn(xch, domid);
+
+ if ( rc <= 0 )
+ return rc;
+
+ *gpfn = rc + 1;
+
+ return 0;
+}
+
/*
* Local variables:
* mode: C
#include "xg_private.h"
#include "xc_dom.h"
+#include "xc_core.h"
#include <xen/hvm/params.h>
#include <xen/grant_table.h>
domid_t xenstore_domid)
{
int rc;
- xen_pfn_t max_gfn;
+ xen_pfn_t scratch_gpfn;
struct xen_add_to_physmap xatp = {
.domid = domid,
.space = XENMAPSPACE_grant_table,
.domid = domid,
};
- max_gfn = xc_domain_maximum_gpfn(xch, domid);
- if ( max_gfn <= 0 ) {
+ rc = xc_core_arch_get_scratch_gpfn(xch, domid, &scratch_gpfn);
+ if ( rc < 0 )
+ {
xc_dom_panic(xch, XC_INTERNAL_ERROR,
- "%s: failed to get max gfn "
+ "%s: failed to get a scratch gfn "
"[errno=%d]\n",
__FUNCTION__, errno);
return -1;
}
- xatp.gpfn = max_gfn + 1;
- xrfp.gpfn = max_gfn + 1;
+ xatp.gpfn = scratch_gpfn;
+ xrfp.gpfn = scratch_gpfn;
+
+ xc_dom_printf(xch, "%s: called, pfn=0x%"PRI_xen_pfn, __FUNCTION__,
+ scratch_gpfn);
+
rc = do_memory_op(xch, XENMEM_add_to_physmap, &xatp, sizeof(xatp));
if ( rc != 0 )